﻿using LibraryGuard.Interfaces;
using LibraryGuard.Interfaces.Configuration;

namespace LibraryGuard.Modes
{
	/// <summary>
	/// Normal mode, see <see cref="LibraryGuard.Interfaces.Configuration.Mode.Normal"/>.
	/// </summary>
	public sealed class NormalMode
		: BaseMode
	{
		#region Static Constructor
		static NormalMode()
		{
			Logger = NLog.LogManager.GetLogger("NormalMode");
		}
		#endregion
		
		#region Constructor
		public NormalMode(IConfiguration config, IGuard[] guards, IActionList actionList)
			: base(config, guards, actionList)
		{ }
		#endregion

		#region Overrides
		protected override void ExecuteAction(IActionInfo action)
		{
			if (!action.Execute(this.ActionList))
			{
				Logger.Warn("Cannot execute action, delayed");
				this.RunDelayedTask(() => this.ExecuteAction(action));
			}
		}
		#endregion
	}
}
